//
//  DBJPersonInfoCell.m
//  DBJ
//
//  Created by 肖浩然的mac on 2016/11/16.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJPersonInfoCell.h"
#import <Masonry.h>

@interface DBJPersonInfoCell ()

//名字Label
@property(nonatomic,weak)UILabel *nameLabel;

//内容Label
@property(nonatomic,weak)UILabel *wordLabel;


@end
@implementation DBJPersonInfoCell

-(void)dbjSetupUI{
    //初始化子控制器
    [self setupUI];
}

-(void)setupUI{
    //1.创建对应的名字
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.textColor = [UIColor lightGrayColor];
    
    //记录
    self.nameLabel = nameLabel;
    [self.contentView addSubview:nameLabel];
    
    //间距
    CGFloat margin = 10;
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.contentView).offset(margin);
        make.size.mas_equalTo(CGSizeMake(80, 22));
        make.bottom.mas_equalTo(self.contentView).offset(-margin);
    }];
    
    //2.接收文字label
    UILabel *wordLabel = [[UILabel alloc]init];
    
    //记录
    self.wordLabel = wordLabel;
    self.wordLabel.textColor = [UIColor lightGrayColor];
    self.wordLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:wordLabel];
    [wordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel.mas_right);
        make.size.mas_equalTo(CGSizeMake(250, 22));
        make.bottom.mas_equalTo(self.contentView).offset(-margin);
    }];
    
  //3.尖尖图标
//    UIImageView *imageView = [[UIImageView alloc]init];
//    
//    UIImage *im = [UIImage imageNamed:@"position-right"];
//    imageView.image = im;
//    [imageView sizeToFit];
//    
//    [self.contentView addSubview:imageView];
//    
//    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.size.mas_equalTo(CGSizeMake(10, 16));
//        make.right.mas_equalTo(self.contentView).offset(-margin);
//        make.bottom.mas_equalTo(self.contentView).offset(-margin);
//    }];
    
    //数据的回调
    if (self.labelBlock != nil) {
        NSString *label = self.wordLabel.text;
        self.labelBlock(label);
    }
}

//setter
-(void)setInFoModel:(NSDictionary *)inFoModel{
    _inFoModel = inFoModel;
    NSString *key = [inFoModel allKeys].lastObject;
    self.nameLabel.text = key;
    self.wordLabel.text = [NSString stringWithFormat:@"%@",inFoModel[key]];
}

@end
